package com.potenza.training.interview.controller;

import com.potenza.training.interview.entity.InterviewFeedbackEntity;
import com.potenza.training.interview.service.InterviewFeedbackService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 面试反馈
 *
 * @author lihonggang
 * @email lihonggang@gmail.com
 * @date 2021-07-28 18:57:10
 */
@RestController
@RequestMapping("interview/interviewfeedback")
public class InterviewFeedbackController {
    @Autowired
    private InterviewFeedbackService interviewFeedbackService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("interview:interviewfeedback:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = interviewFeedbackService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("interview:interviewfeedback:info")
    public R info(@PathVariable("id") Integer id){
		InterviewFeedbackEntity interviewFeedback = interviewFeedbackService.getById(id);

        return R.ok().put("interviewFeedback", interviewFeedback);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("interview:interviewfeedback:save")
    public R save(@RequestBody InterviewFeedbackEntity interviewFeedback){
		interviewFeedbackService.save(interviewFeedback);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("interview:interviewfeedback:update")
    public R update(@RequestBody InterviewFeedbackEntity interviewFeedback){
		interviewFeedbackService.updateById(interviewFeedback);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("interview:interviewfeedback:delete")
    public R delete(@RequestBody Integer[] ids){
		interviewFeedbackService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 查询
     */
    @RequestMapping("/findByinvitationId/{id}/{uid}")
    @RequiresPermissions("interview:interviewfeedback:findByinvitationId")
    public R findByinvitationId(@PathVariable Integer id,@PathVariable Integer uid){
        InterviewFeedbackEntity feedback = interviewFeedbackService.findByinvitationId(id,uid);

        return R.ok().put("feedback",feedback);
    }
}
